<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>GNUcode.me</title><id>https://gnucode.me/feeds/tags/OpenBSD VM qemu.xml</id><subtitle>Tag: OpenBSD VM qemu</subtitle><updated>2024-05-08T13:40:23Z</updated><link href="https://gnucode.me/feeds/tags/OpenBSD VM qemu.xml" rel="self" /><link href="https://gnucode.me" /><entry><title>Installing OpenBSD on a VM</title><id>https://gnucode.me/installing-openbsd-on-a-vm.html</id><author><name>Joshua Branson</name><email>jbranso@dismail.de</email></author><updated>2022-08-05T07:00:00Z</updated><link href="https://gnucode.me/installing-openbsd-on-a-vm.html" rel="alternate" /><content type="html">&lt;p&gt;I am of the opinion, that in order to learn how to use an operating system, you
have to use it often.  Since I am madly in love with Guix System, but have an
interest in the GNU/Hurd and OpenBSD, I might as well install those OSs on a
virtual machine!  I have already done that with the GNU/Hurd, and today I also
did it for OpenBSD.&lt;/p&gt;&lt;p&gt;I was not that hard to do.  I used this guide to &lt;a href=&quot;https://wiki.qemu.org/index.php/Hosts/BSD#OpenBSD&quot;&gt;install OpenBSD on a vm.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;First let’s create a qemu img for OpenBSD.&lt;/p&gt;&lt;p&gt;&lt;code&gt;qemu-img create -f qcow2 hd0.qcow2.img 100G&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Now, let's create an install script.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;cat install-bsd.sh

#!/bin/sh

qemu-system-x86_64 -m 2048 \
  -no-reboot \
  -cdrom cd71.iso \
  -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \
  -enable-kvm \
  -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \
  -device virtio-net,netdev=mynet0 \
  -smp 2&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As always installing OpenBSD is an absolute breeze.  I do not know how to
manually partition things, so I just chose the auto install.  Also OpenBSD
supports a &lt;code&gt;us.swapcaps.dvorak&lt;/code&gt; keyboard layout.  That’s my layout!  How cool is
that!?  And it sets up that layout for the console and X by default.  Guix
System does that, but not so well for wayland.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;cat run-bsd.sh&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now let's create a run script.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;#!/bin/sh

qemu-system-x86_64 -m 4G \
  -no-reboot \
  -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \
  -enable-kvm \
  -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \
  -device virtio-net,netdev=mynet0 \
  -smp 2&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I find the &lt;code&gt;-no-reboot&lt;/code&gt; option helpful, because OpenBSD likes to try to autoreboot
itself, even when you give it the command: &lt;code&gt;halt&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;I have ran OpenBSD before for about a week before, and it is always a pleasure
to read man afterboot.  With OpenBSD the man pages are absolutely excelent.&lt;/p&gt;&lt;p&gt;One of the first things I did was:&lt;/p&gt;&lt;p&gt;&lt;code&gt;# cp /etc/examples/doas.conf /etc/&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Now my user &lt;code&gt;berno&lt;/code&gt; can use &lt;code&gt;doas&lt;/code&gt; to install packages!  Let’s install Emacs!&lt;/p&gt;&lt;p&gt;&lt;code&gt;doas pkg_add emacs&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Also OpenBSD has a habit of printing clues to the console after you type in a
command. For examle, after you install a package, OpenBSD tells you that it has
installed README files in &lt;code&gt;/usr/local/bsah/blah/README/emacs/&lt;/code&gt;. I find it really
cool that it reminds you of this.  Also, when you run &lt;code&gt;doas syspatch&lt;/code&gt; it will
tell you that it updated syspatch.  It  will also say something like:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Please run syspatch again to apply the patches.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;That’s a handy tip!  And indeed, &lt;code&gt;doas syspatch -c&lt;/code&gt; showed that the patches had
not yet been applied.&lt;/p&gt;&lt;p&gt;Also whilst searching for the internet for how to install OpenBSD on a vm image,
I came accross &lt;a href=&quot;https://www.skreutz.com/posts/autoinstall-openbsd-on-qemu/&quot;&gt;blog post&lt;/a&gt; that describes that you can automate OpenBSD installs.
That might be something to play with later!&lt;/p&gt;&lt;p&gt;I would like to also set up my local OpenBSD to set up ssh.  That way I could do
something like this:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;#+BEGIN_SRC shell :dir /ssh:berno@localhost:/home/berno  :exports both
ls | wc -l
#+END_SRC

#+RESULTS:
: 9&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I also think it would be fabulous if the OpenBSD team started to make a
guix-like package manager/distro.  I imagine that they could use perl to do it,
since it seems like OpenBSD has embraced perl as their scripting language, and I
think it their man pages show that perl can use some rather low lever operating
system interfaces.&lt;/p&gt;</content></entry></feed>